<template><div><p>本文档最新版为 <a href="https://learnku.com/docs/laravel/10.x" target="_blank" rel="noopener noreferrer">10.x</a>，旧版本可能放弃维护，推荐阅读最新版！</p>
<h2 id="升级指南" tabindex="-1"><a class="header-anchor" href="#升级指南"><span>升级指南</span></a></h2>
<ul>
<li><a href="#upgrade-6.0">从 5.8 升级到 6.0</a></li>
</ul>
<h2 id="高影响变化" tabindex="-1"><a class="header-anchor" href="#高影响变化"><span>高影响变化</span></a></h2>
<ul>
<li><a href="#authorized-resources">授权认证资源 &amp; <code v-pre>viewAny</code></a></li>
<li><a href="#helpers">字符串和数组辅助函数</a></li>
</ul>
<h2 id="中影响变化" tabindex="-1"><a class="header-anchor" href="#中影响变化"><span>中影响变化</span></a></h2>
<ul>
<li><a href="#the-register-controller">授权认证 <code v-pre>RegisterController</code></a></li>
<li><a href="#carbon-support">Carbon 1.x 不再支持</a></li>
<li><a href="#capsule-table">数据库 <code v-pre>Capsule::table</code> 方法</a></li>
<li><a href="#eloquent-to-array">Eloquent Arrayable &amp; <code v-pre>toArray</code></a></li>
<li><a href="#belongs-to-update">Eloquent <code v-pre>BelongsTo::update</code> 方法</a></li>
<li><a href="#eloquent-primary-key-type">Eloquent 主键类型</a></li>
<li><a href="#trans-and-trans-choice">本地化 <code v-pre>Lang::trans</code> 和 <code v-pre>Lang::transChoice</code> 方法</a></li>
<li><a href="#get-from-json">本地化 <code v-pre>Lang::getFromJson</code> 方法</a></li>
<li><a href="#queue-retry-limit">队列重试限制</a></li>
<li><a href="#email-verification-route">重发 Email 验证路由</a></li>
<li><a href="#the-input-facade"><code v-pre>Input</code> Facade</a></li>
</ul>
<h2 id="从-5-8-升级到-6-0" tabindex="-1"><a class="header-anchor" href="#从-5-8-升级到-6-0"><span>从 5.8 升级到 6.0</span></a></h2>
<h4 id="预计升级时间-一小时" tabindex="-1"><a class="header-anchor" href="#预计升级时间-一小时"><span>预计升级时间: 一小时</span></a></h4>
<blockquote>
<p>{注意} 我们尝试记录了每个可能的主要变化。由于这些主要变化中的一些是在框架的模糊部分，因此这些变化中的某些部分可能会对应用程序产生实际影响。</p>
</blockquote>
<h3 id="需要-php-7-2-版本" tabindex="-1"><a class="header-anchor" href="#需要-php-7-2-版本"><span>需要 PHP 7.2 版本</span></a></h3>
<p><strong>影响程度：中</strong></p>
<p>PHP 7.1 版本从 2019 年十二月起将不再进行主动维护了。因此，Laravel 6.0 需要 PHP 7.2 或以上版本。</p>
<h3 id="升级依赖" tabindex="-1"><a class="header-anchor" href="#升级依赖"><span>升级依赖</span></a></h3>
<p>升级 <code v-pre>laravel/framework</code> 依赖于 <code v-pre>composer.json</code> 文件中指定的 <code v-pre>^6.0</code> 。</p>
<p>接下来，检查应用程序使用的任何第三方软件包，验证其是否适配 Laravel 6 支持的版本。</p>
<h3 id="授权认证" tabindex="-1"><a class="header-anchor" href="#授权认证"><span>授权认证</span></a></h3>
<h4 id="认证资源-viewany" tabindex="-1"><a class="header-anchor" href="#认证资源-viewany"><span>认证资源 &amp; <code v-pre>viewAny</code></span></a></h4>
<p><strong>影响程度：高</strong></p>
<p>使用 <code v-pre>authorizeResource</code> 方法附加到控制器中的授权策略现在应该要定义一个 <code v-pre>viewAny</code> 方法，当用户访问控制器中的 <code v-pre>index</code> 方法它就会被调用。换而言之，未经授权去访问控制器中的 <code v-pre>index</code> 方法将被拒绝。</p>
<h4 id="registercontroller-控制器" tabindex="-1"><a class="header-anchor" href="#registercontroller-控制器"><span><code v-pre>RegisterController</code> 控制器</span></a></h4>
<p><strong>影响程度: 中</strong></p>
<p>如果你重写过 <code v-pre>Laravel</code> 框架中 <code v-pre>RegisterController</code> 的 <code v-pre>register</code> 或 <code v-pre>registered</code> 方法 ， 则应确保在对应方法中调用了 <code v-pre>parent::register</code> 和 <code v-pre>parent::registered</code> 方法，因为 <code v-pre>Illuminate\Auth\Events\Registered</code> 事件触发和新用户登录逻辑现在被移到 <code v-pre>registered</code> 方法中了，如果你重写了这些方法而没有调用对应的父级方法，则用户注册处理会失败。</p>
<h4 id="授权响应" tabindex="-1"><a class="header-anchor" href="#授权响应"><span>授权响应</span></a></h4>
<p><strong>影响程度: 低</strong></p>
<p><code v-pre>Illuminate\Auth\Access\Response</code> 类的构造函数参数已经改变。你应该更新相应的代码。 如果你没有手动构造过授权响应实例，只是在策略类中使用了 <code v-pre>allow</code> 和 <code v-pre>deny</code> 实例方法， 则不需要更新：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token doc-comment comment">/**</span>
<span class="line"> * Create a new response.</span>
<span class="line"> *</span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">bool</span></span>  <span class="token parameter">$allowed</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$message</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">mixed</span></span>  <span class="token parameter">$code</span></span>
<span class="line"> * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">void</span></span></span>
<span class="line"> */</span></span>
<span class="line"><span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">__construct</span><span class="token punctuation">(</span><span class="token variable">$allowed</span><span class="token punctuation">,</span> <span class="token variable">$message</span> <span class="token operator">=</span> <span class="token string single-quoted-string">''</span><span class="token punctuation">,</span> <span class="token variable">$code</span> <span class="token operator">=</span> <span class="token constant">null</span><span class="token punctuation">)</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="illuminate-contracts-auth-access-gate-契约" tabindex="-1"><a class="header-anchor" href="#illuminate-contracts-auth-access-gate-契约"><span><code v-pre>Illuminate\Contracts\Auth\Access\Gate</code> 契约</span></a></h4>
<p><strong>影响程度：低</strong></p>
<p><code v-pre>Illuminate\Contracts\Auth\Access\Gate</code> 契约迎来了一个新的方法 <code v-pre>inspect</code> 。如果你正在手动实现这个接口，你应该将这个方法添加到你的实现中。</p>
<h3 id="carbon" tabindex="-1"><a class="header-anchor" href="#carbon"><span>Carbon</span></a></h3>
<h4 id="carbon-1-x-不再支持" tabindex="-1"><a class="header-anchor" href="#carbon-1-x-不再支持"><span>Carbon 1.x 不再支持</span></a></h4>
<p><strong>影响程度：中</strong></p>
<p>Carbon 1.x <a href="https://github.com/laravel/framework/pull/28683" target="_blank" rel="noopener noreferrer">不再支持</a> 因为它的维护已经快要结束了。请将你的应用程序更新到 Carbon 2.0。</p>
<h3 id="配置" tabindex="-1"><a class="header-anchor" href="#配置"><span>配置</span></a></h3>
<h4 id="aws-region-环境变量" tabindex="-1"><a class="header-anchor" href="#aws-region-环境变量"><span><code v-pre>AWS_REGION</code> 环境变量</span></a></h4>
<p><strong>影响程度：可选</strong></p>
<p>如果你打算使用 <a href="https://vapor.laravel.com/" target="_blank" rel="noopener noreferrer">Laravel Vapor</a>，你应该将 <code v-pre>config</code> 目录中所有的 <code v-pre>AWS_REGION</code> 更新为 <code v-pre>AWS_DEFAULT_REGION</code> 。另外，你应该在你的 <code v-pre>.env</code> 文件中，更新这个环境变量的名称。</p>
<h3 id="database" tabindex="-1"><a class="header-anchor" href="#database"><span>Database</span></a></h3>
<h4 id="capsule-类的-table-方法" tabindex="-1"><a class="header-anchor" href="#capsule-类的-table-方法"><span>Capsule 类的 <code v-pre>table</code> 方法</span></a></h4>
<p><strong>影响程度：中等</strong></p>
<blockquote>
<p>注意： 此更改仅适用于使用 <code v-pre>illuminate/database</code> 作为依赖项的非 Laravel 应用程序。</p>
</blockquote>
<p><code v-pre>Illuminate\Database\Capsule\Manager</code> 类的 <code v-pre>table</code> 签名已更新为接受表别名作为其第二个参数。如果您在 Laravel 应用程序之外使用 <code v-pre>illuminate/database</code> ，则应相应地更新对此方法的任何调用</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token doc-comment comment">/**</span>
<span class="line"> * 获得流畅的查询构建器实例</span>
<span class="line"> *</span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token punctuation">\</span>Closure<span class="token punctuation">|</span><span class="token punctuation">\</span>Illuminate<span class="token punctuation">\</span>Database<span class="token punctuation">\</span>Query<span class="token punctuation">\</span>Builder<span class="token punctuation">|</span><span class="token keyword">string</span></span>  <span class="token parameter">$table</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span><span class="token punctuation">|</span><span class="token keyword">null</span></span>  <span class="token parameter">$as</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span><span class="token punctuation">|</span><span class="token keyword">null</span></span>  <span class="token parameter">$connection</span></span>
<span class="line"> * <span class="token keyword">@return</span> <span class="token class-name"><span class="token punctuation">\</span>Illuminate<span class="token punctuation">\</span>Database<span class="token punctuation">\</span>Query<span class="token punctuation">\</span>Builder</span></span>
<span class="line"> */</span></span>
<span class="line"><span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">function</span> <span class="token function-definition function">table</span><span class="token punctuation">(</span><span class="token variable">$table</span><span class="token punctuation">,</span> <span class="token variable">$as</span> <span class="token operator">=</span> <span class="token constant">null</span><span class="token punctuation">,</span> <span class="token variable">$connection</span> <span class="token operator">=</span> <span class="token constant">null</span><span class="token punctuation">)</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="cursor-方法" tabindex="-1"><a class="header-anchor" href="#cursor-方法"><span><code v-pre>cursor</code> 方法</span></a></h4>
<p><strong>影响程度：低</strong></p>
<p><code v-pre>cursor</code> 方法现在返回一个 <code v-pre>Illuminate\Support\LazyCollection</code> 的实例，而不是一个 <code v-pre>Generator</code> ， <code v-pre>LazyCollection</code> 可以像生成器一样迭代：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$users</span> <span class="token operator">=</span> <span class="token class-name class-name-fully-qualified static-context">App<span class="token punctuation">\</span>User</span><span class="token operator">::</span><span class="token function">cursor</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$users</span> <span class="token keyword">as</span> <span class="token variable">$user</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">//</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="eloquent-集合" tabindex="-1"><a class="header-anchor" href="#eloquent-集合"><span>Eloquent 集合</span></a></h3>
<h4 id="belongsto-update-方法" tabindex="-1"><a class="header-anchor" href="#belongsto-update-方法"><span><code v-pre>BelongsTo::update</code> 方法</span></a></h4>
<p><strong>影响程度：中</strong></p>
<p>为了保持一致性，现在 <code v-pre>BelongsTo</code> 关系模型的 <code v-pre>update</code> 方法起到了临时更新查询的作用，这意味着它不提供批量赋值保护或触发 Eloquent 事件。这使得该关联关系与所有其它关联关系类型的 <code v-pre>update</code> 方法一致。</p>
<p>如果你通过 <code v-pre>BelongsTo</code> 更新关联关系连接的模型，并获取批量赋值更新保护和事件触发，则需要在模型自身上调用 <code v-pre>update</code> 方法：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token comment">// 临时查询…没有批量赋值保护或事件触发…</span></span>
<span class="line"><span class="token variable">$post</span><span class="token operator">-></span><span class="token function">user</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">update</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'foo'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'bar'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// 模型更新…提供批量赋值保护和事件触发…</span></span>
<span class="line"><span class="token variable">$post</span><span class="token operator">-></span><span class="token property">user</span><span class="token operator">-></span><span class="token function">update</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string single-quoted-string">'foo'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'bar'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="arrayable-类-toarray-方法" tabindex="-1"><a class="header-anchor" href="#arrayable-类-toarray-方法"><span>Arrayable 类 &amp; <code v-pre>toArray</code> 方法</span></a></h4>
<p><strong>影响程度：中</strong></p>
<p>现在 Eloquent 集合的 <code v-pre>toArray</code> 方法实现了 <code v-pre>Illuminate\Contracts\Support\Arrayable</code> 类方法，将会把任何属性类型强制转换为数组。</p>
<h4 id="主键类型的声明" tabindex="-1"><a class="header-anchor" href="#主键类型的声明"><span>主键类型的声明</span></a></h4>
<p><strong>影响程度：中</strong></p>
<p>Laravel 6.0 已经收到整数类型密钥的<a href="https://github.com/laravel/framework/pull/28153" target="_blank" rel="noopener noreferrer">性能优化</a> 建议。如果你使用字符串作为模型的主键，那么你应该在模型属性的 <code v-pre>$keyType</code> 上声明密钥类型：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token doc-comment comment">/**</span>
<span class="line"> * 主键 ID 的「类型」。</span>
<span class="line"> *</span>
<span class="line"> * <span class="token keyword">@var</span> <span class="token class-name"><span class="token keyword">string</span></span></span>
<span class="line"> */</span></span>
<span class="line"><span class="token keyword">protected</span> <span class="token variable">$keyType</span> <span class="token operator">=</span> <span class="token string single-quoted-string">'string'</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="email-验证" tabindex="-1"><a class="header-anchor" href="#email-验证"><span>Email 验证</span></a></h3>
<h4 id="重发验证路由-http-方法" tabindex="-1"><a class="header-anchor" href="#重发验证路由-http-方法"><span>重发验证路由 HTTP 方法</span></a></h4>
<p><strong>影响程度：中</strong></p>
<p>为了防止可能的 CSRF 攻击，当你使用 Laravel 内置 email 验证时，系统注册的路由 <code v-pre>email/resend</code> 请求方式已经从 <code v-pre>GET</code> 变更为 <code v-pre>POST</code>。因此，请求此路由时，需要前端代码发送正确的请求方式。例如你可以使用如下内置的 email 验证模板：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token punctuation">{</span><span class="token punctuation">{</span> <span class="token function">__</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'Before proceeding, please check your email for a verification link.'</span><span class="token punctuation">)</span> <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">{</span><span class="token punctuation">{</span> <span class="token function">__</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'If you did not receive the email'</span><span class="token punctuation">)</span> <span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token punctuation">,</span></span>
<span class="line"></span>
<span class="line"><span class="token operator">&lt;</span>form <span class="token keyword">class</span><span class="token operator">=</span><span class="token string double-quoted-string">"d-inline"</span> method<span class="token operator">=</span><span class="token string double-quoted-string">"POST"</span> action<span class="token operator">=</span><span class="token string double-quoted-string">"{{ route('verification.resend') }}"</span><span class="token operator">></span></span>
<span class="line">    @csrf</span>
<span class="line"></span>
<span class="line">    <span class="token operator">&lt;</span>button type<span class="token operator">=</span><span class="token string double-quoted-string">"submit"</span> <span class="token keyword">class</span><span class="token operator">=</span><span class="token string double-quoted-string">"btn btn-link p-0 m-0 align-baseline"</span><span class="token operator">></span></span>
<span class="line">        <span class="token punctuation">{</span><span class="token punctuation">{</span> <span class="token function">__</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'click here to request another'</span><span class="token punctuation">)</span> <span class="token punctuation">}</span><span class="token punctuation">}</span></span>
<span class="line">    <span class="token operator">&lt;</span><span class="token operator">/</span>button<span class="token operator">></span><span class="token operator">.</span></span>
<span class="line"><span class="token operator">&lt;</span><span class="token operator">/</span>form<span class="token operator">></span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="mustverifyemail-契约" tabindex="-1"><a class="header-anchor" href="#mustverifyemail-契约"><span><code v-pre>MustVerifyEmail</code> 契约</span></a></h4>
<p><strong>影响程度：低</strong></p>
<p>一个新的方法 <code v-pre>getEmailForVerification</code> 加入到了 <code v-pre>Illuminate\Contracts\Auth\MustVerifyEmail</code> 契约。如果你正在手动实现这个契约，你应该实现这个方法。这个方法应该返回对象关联的电子邮箱地址。如果你的 <code v-pre>App\User</code> 模型正在使用 <code v-pre>Illuminate\Auth\MustVerifyEmail</code> 特性，不需要更改，因为这个特性会帮你实现这个方法。</p>
<h3 id="辅助函数" tabindex="-1"><a class="header-anchor" href="#辅助函数"><span>辅助函数</span></a></h3>
<h4 id="string-array-辅助函数包" tabindex="-1"><a class="header-anchor" href="#string-array-辅助函数包"><span>String &amp; Array 辅助函数包</span></a></h4>
<p><strong>影响程度：高</strong></p>
<p>所有的 <code v-pre>str_</code> 和 <code v-pre>array_</code> 辅助函数都已经从框架中移除，并移动到新的 <code v-pre>laravel/helpers</code> Composer 包中。如果需要，你可以使用 <code v-pre>Illuminate\Support\Str</code> 和 <code v-pre>Illuminate\Support\Arr</code> 类来更新这些辅助函数的所有调用。或者，你也可以在你的应用程序中添加新的 <code v-pre>laravel/helpers</code> 包来继续使用这些辅助函数：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">composer <span class="token keyword">require</span> laravel<span class="token operator">/</span>helpers</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3 id="本地化" tabindex="-1"><a class="header-anchor" href="#本地化"><span>本地化</span></a></h3>
<h4 id="lang-trans-lang-transchoice-方法" tabindex="-1"><a class="header-anchor" href="#lang-trans-lang-transchoice-方法"><span><code v-pre>Lang::trans</code> &amp; <code v-pre>Lang::transChoice</code> 方法</span></a></h4>
<p><strong>影响程度：中</strong></p>
<p>翻译器的<code v-pre>Lang::trans</code> 和 <code v-pre>Lang::transChoice</code> 方法已重命名为 <code v-pre>Lang::get</code> 和 <code v-pre>Lang::choice</code> 。</p>
<p>另外，如果你正在手动实现 <code v-pre>Illuminate\Contracts\Translation\Translator</code> 契约，你应该将你实现的 <code v-pre>trans</code> 和 <code v-pre>transChoice</code> 方法更新为 <code v-pre>get</code> 和 <code v-pre>choice</code>。</p>
<h4 id="lang-getfromjson方法" tabindex="-1"><a class="header-anchor" href="#lang-getfromjson方法"><span><code v-pre>Lang::getFromJson</code>方法</span></a></h4>
<p><strong>影响程度: 中</strong></p>
<p><code v-pre>Lang::get</code> 和 <code v-pre>Lang::getFromJson</code>方法已被合并。原先调用<code v-pre>Lang::getFromJson</code>方法的需要更改为调用<code v-pre>Lang::get</code>方法。</p>
<h3 id="邮件" tabindex="-1"><a class="header-anchor" href="#邮件"><span>邮件</span></a></h3>
<h4 id="mandrill-和-sparkpost-驱动已经被移除" tabindex="-1"><a class="header-anchor" href="#mandrill-和-sparkpost-驱动已经被移除"><span>Mandrill 和 SparkPost 驱动已经被移除</span></a></h4>
<p><strong>影响程度: 低</strong></p>
<p><code v-pre>mandrill</code> 和<code v-pre>sparkpost</code>邮件驱动已经被移除，如果你想继续使用这两个驱动中的任意一个，我们鼓励你选择采用一个社区支持的包来提供驱动。</p>
<h3 id="通知" tabindex="-1"><a class="header-anchor" href="#通知"><span>通知</span></a></h3>
<h4 id="nexmo路由已被移除" tabindex="-1"><a class="header-anchor" href="#nexmo路由已被移除"><span>Nexmo路由已被移除</span></a></h4>
<p><strong>影响程度: 低</strong></p>
<p>Nexmo通知通道的延迟部分已经被从框架的核心中移除。如果你依赖于Nexmo通知路由，你应该在你的通知实体中手动的实现 <code v-pre>routeNotificationForNexmo</code>方法。 <a href="https://learnku.com/docs/laravel/6.x/notifications#routing-sms-notifications" target="_blank" rel="noopener noreferrer">详细描述请看这</a>.</p>
<h3 id="重置密码" tabindex="-1"><a class="header-anchor" href="#重置密码"><span>重置密码</span></a></h3>
<h4 id="密码验证" tabindex="-1"><a class="header-anchor" href="#密码验证"><span>密码验证</span></a></h4>
<p><strong>影响程度: 低</strong></p>
<p><code v-pre>PasswordBroker</code>不再限制或者验证密码。在 <code v-pre>ResetPasswordController</code>类中密码验证已经被处理过了，这使得代理的验证显得冗余并且无法自定义。如果你在内置 <code v-pre>ResetPasswordController</code>类中手动使用<code v-pre>PasswordBroker</code>（或者<code v-pre>Password</code>门面），你应该在把所有密码传递给代理之前进行验证。</p>
<h3 id="队列" tabindex="-1"><a class="header-anchor" href="#队列"><span>队列</span></a></h3>
<h4 id="队列重试限制" tabindex="-1"><a class="header-anchor" href="#队列重试限制"><span>队列重试限制</span></a></h4>
<p><strong>影响程度: 中</strong></p>
<p>在之前的 Laravel 版本 中, <code v-pre>php artisan queue:work</code> 命令会无限期重试队列任务，从 Laravel 6.0 开始，该命令默认只会重试队列任务一次，如果你想要强制任务无限期重试， 可以通过<code v-pre>--tries=0</code> 指定:</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">php artisan queue<span class="token punctuation">:</span>work <span class="token operator">--</span>tries<span class="token operator">=</span><span class="token number">0</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>另外，请确保你的数据库中包含 <code v-pre>failed_jobs</code> 数据表. 你可以通过 Artisan 命令 <code v-pre>queue:failed-table</code>来生成这个迁移:</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">php artisan queue<span class="token punctuation">:</span>failed<span class="token operator">-</span>table</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h3 id="请求" tabindex="-1"><a class="header-anchor" href="#请求"><span>请求</span></a></h3>
<h4 id="input-门面" tabindex="-1"><a class="header-anchor" href="#input-门面"><span><code v-pre>Input</code> 门面</span></a></h4>
<p><strong>影响程度: 中</strong></p>
<p><code v-pre>Input</code> 门面是 <code v-pre>Request</code> 门面的复制品, 已经被移除. 如果你在使用<code v-pre>Input::get</code> 方法, 应该将其替换成 <code v-pre>Request::input</code> 方法.所有其他调用 <code v-pre>Input</code> 门面的地方也同样需替换为 <code v-pre>Request</code> 门面.</p>
<h3 id="任务调度" tabindex="-1"><a class="header-anchor" href="#任务调度"><span>任务调度</span></a></h3>
<h4 id="between-方法" tabindex="-1"><a class="header-anchor" href="#between-方法"><span><code v-pre>between</code> 方法</span></a></h4>
<p><strong>影响程度: 低</strong></p>
<p>在 Laravel 之前的版本中， 调度器的 <code v-pre>between</code> 方法出现了跨越日期边界的混乱行为。 例如：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token variable">$schedule</span><span class="token operator">-></span><span class="token function">command</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'list'</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">between</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'23:00'</span><span class="token punctuation">,</span> <span class="token string single-quoted-string">'4:00'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>对于大多数用户，上述调度预期行为是在 23:00 至 4:00 之间每分钟运行一次 <code v-pre>list</code> 命令。 然而， 在 Laravel 之前的版本中，调度器会在 4:00 至 23:00 之间每分钟运行一次 <code v-pre>list</code> 命令，刚好颠倒了时间阈值。 在 Laravel 6.0 中，这一行为已被纠正。</p>
<h3 id="存储" tabindex="-1"><a class="header-anchor" href="#存储"><span>存储</span></a></h3>
<h4 id="rackspace-存储驱动被移除" tabindex="-1"><a class="header-anchor" href="#rackspace-存储驱动被移除"><span>Rackspace 存储驱动被移除</span></a></h4>
<p><strong>影响程度: 低</strong></p>
<p>存储驱动 <code v-pre>rackspace</code> 已被移除。如果你想继续使用 Rackspace 作为存储驱动，我们建议您使用提供此驱动的社区所维护的扩展包。</p>
<h3 id="url-生成" tabindex="-1"><a class="header-anchor" href="#url-生成"><span>URL 生成</span></a></h3>
<h4 id="路由-url-生成-提取参数" tabindex="-1"><a class="header-anchor" href="#路由-url-生成-提取参数"><span>路由 URL 生成 &amp; 提取参数</span></a></h4>
<p>在之前版本的 Laravel 中，传递关联数组参数到 <code v-pre>route</code> 辅助函数或者 <code v-pre>URL::route</code> 方法生成指定路由（包含可选参数）对应 URL 时偶尔会出现将这些参数作为 URI 值的现象，即使传递参数值在路由路径中没有匹配键。从 Laravel 6.0 开始，这些值会被追加到查询字符串中，如下所示：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token class-name static-context">Route</span><span class="token operator">::</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'/profile/{location?}'</span><span class="token punctuation">,</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$location</span> <span class="token operator">=</span> <span class="token constant">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token comment">//</span></span>
<span class="line"><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">name</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// Laravel 5.8: http://example.com/profile/active</span></span>
<span class="line"><span class="token keyword">echo</span> <span class="token function">route</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile'</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'status'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'active'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// Laravel 6.0: http://example.com/profile?status=active</span></span>
<span class="line"><span class="token keyword">echo</span> <span class="token function">route</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'profile'</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'status'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'active'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    </span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="其他" tabindex="-1"><a class="header-anchor" href="#其他"><span>其他</span></a></h3>
<p>我们还鼓励您查看 <code v-pre>laravel/laravel</code> <a href="https://github.com/laravel/laravel" target="_blank" rel="noopener noreferrer">GitHub 仓库</a> 代码更新日志。 尽管许多更新不是必须的，但您可能希望将这些文件与您的应用程序保持一致。其中的一些更新已经在这篇升级指南中覆盖到了，但是还有很多其他的小更新比如配置文件或注释的微调，就不会一一指出。你可以通过 <a href="https://github.com/laravel/laravel/compare/5.8...master" target="_blank" rel="noopener noreferrer">GitHub comparison tool</a> 轻松查看变更，以便选择那些对你而言更为重要的更新。</p>
<blockquote>
<p>本译文仅用于学习和交流目的，转载请务必注明文章译者、出处、和本文链接<br>
我们的翻译工作遵照 <a href="https://learnku.com/docs/guide/cc4.0/6589" target="_blank" rel="noopener noreferrer">CC 协议</a>，如果我们的工作有侵犯到您的权益，请及时联系我们。</p>
</blockquote>
<hr>
<blockquote>
<p>原文地址：<a href="https://learnku.com/docs/laravel/6.x/upgrade/5122" target="_blank" rel="noopener noreferrer">https://learnku.com/docs/laravel/6.x/upg...</a></p>
<p>译文地址：<a href="https://learnku.com/docs/laravel/6.x/upgrade/5122" target="_blank" rel="noopener noreferrer">https://learnku.com/docs/laravel/6.x/upg...</a></p>
</blockquote>
</div></template>


